// this file is used to handle the slice of userId
import { createSlice } from '@reduxjs/toolkit';
import dayjs from 'dayjs';

export const displaySlice = createSlice({
  name: 'displaySlice',
  initialState: {
    calendar: false, // 时间选择器的显示或隐藏
    age: false, // 年龄输入框的显示或隐藏
    fourFunc: false, // +号点击后，4个功能按钮的显示或隐藏
    calendarDate: dayjs(Date()).format('dddd, DD MMM YYYY'), // 时间选择器所选择的时间，不能传对象，直接时间戳
    calendarDateValueOf: dayjs(Date()).startOf('day').valueOf(), // 时间选择器的时间戳
    // homeHeaderOne: false, // 首页卡路里数值组件的显示或隐藏
    close: false, // 订阅页里的关闭按钮 false: 显示按钮   true: 隐藏按钮
    isSubscribing: false, // 订阅页菊花
    itemPayCode: '', // 订阅页所选择的item的code
    isHasUser: false, // 是否有用户信息
    steps: 0, // 步数
    calories: 0, // 卡路里
    runningCalories: 0, // 运动时，所产生的卡路里
  },
  reducers: {
    setCalendar: (state, action) => {
      state.calendar = action.payload;
    },
    setFourFunc: (state, action) => {
      state.fourFunc = action.payload;
    },
    setCalendarDate: (state, action) => {
      state.calendarDate = action.payload;
    },
    setCalendarDateValueOf: (state, action) => {
      state.calendarDateValueOf = action.payload;
    },
    setAge: (state, action) => {
      state.age = action.payload;
    },
    setClose: (state, action) => {
      state.close = action.payload;
    },
    setReduxIsSubscribing: (state, action) => {
      state.isSubscribing = action.payload;
    },
    setItemPayCode: (state, action) => {
      state.itemPayCode = action.payload;
    },
    setIsHasUser: (state, action) => {
      state.isHasUser = action.payload;
    },
    setSteps: (state, action) => {
      state.steps = action.payload;
    },
    setCalories: (state, action) => {
      state.calories = action.payload;
    },
    setRunningCalories: (state, action) => {
      state.runningCalories = action.payload;
    },
    // setHomeHeaderOne: (state, action) => {
    //   state.homeHeaderOne = action.payload;
    // },
  },
});

export const {
  setCalendar,
  setFourFunc,
  setCalendarDate,
  setAge,
  setClose,
  setReduxIsSubscribing,
  setItemPayCode,
  setIsHasUser,
  setCalendarDateValueOf,
  setSteps,
  setCalories,
  setRunningCalories,
} = displaySlice.actions;

export default displaySlice.reducer;
